package com.cdtye.shuoh.domain.device.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cdtye.common.mybatiscore.base.BaseEntity;
import com.cdtye.shuoh.domain.enums.DeviceConnectStatus;
import com.cdtye.shuoh.domain.enums.DeviceType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 边设备档案信息表
 * @author ZhongWang Wang
 * @date 2022-12-21
 */
@ApiModel("边设备档案信息表")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("IOT_DEVICE")
public class Device extends BaseEntity {
    
    @ApiModelProperty(value = "客户端标识")
    private String clientId;

    @ApiModelProperty(value = "用户名")
    private String userName;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "应用ID")
    private String appId;

    @ApiModelProperty(value = "认证方式")
    private String authMode;

    @ApiModelProperty(value = "设备标识")
    private String deviceIdentification;

    @ApiModelProperty(value = "设备名称")
    private String deviceName;

    @ApiModelProperty(value = "连接实例")
    private String connector;

    @ApiModelProperty(value = "设备描述")
    private String deviceDescription;

    @ApiModelProperty(value = "设备状态： 1启用 || 0禁用")
    private String deviceStatus;

    @ApiModelProperty(value = "连接状态 : 在线：ONLINE || 离线：OFFLINE || 未连接：INIT")
    private String connectStatus;

    @ApiModelProperty(value = "是否遗言")
    private String isWill;

    @ApiModelProperty(value = "设备标签")
    private String deviceTags;

    @ApiModelProperty(value = "产品标识")
    private String productIdentification;

    @ApiModelProperty(value = "产品协议类型 ：mqtt || coap || modbus || http")
    private String protocolType;

    @ApiModelProperty(value = "设备类型")
    private String deviceType;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "ip")
    private String ip;

    @ApiModelProperty(value = "port")
    private String port;

    @ApiModelProperty(value = "address")
    private String address;

    @ApiModelProperty(value = "streamMode")
    private String streamMode;

    @ApiModelProperty(value = "transport")
    private String transport;

    @TableField(exist = false)
    private String deviceTypeName;

    @TableField(exist = false)
    private String model;

    @TableField(exist = false)
    private String deviceStatusName;

    @TableField(exist = false)
    private String connectStatusName;

    @TableField(exist = false)
    private DeviceLocation deviceLocation;

    public String getDeviceTypeName(){
        DeviceType deviceType1 = DeviceType.parseByValue(deviceType);
        if(null == deviceType1){
            return null;
        }
        return deviceType1.getTag();
    }

    public String getDeviceStatusName(){
        if("1".equals(deviceStatus)){
            return "启用";
        }
        return "禁用";
    }

    public String getConnectStatusName(){
        DeviceConnectStatus deviceConnectStatus = DeviceConnectStatus.parseByValue(connectStatus);
        if(null == deviceConnectStatus){
            return null;
        }
        return deviceConnectStatus.getTag();
    }




}